//
//  WBHomeViewModel.swift
//  weibo
//
//  Created by shizb macbook air on 17/8/11.
//  Copyright © 2017年 YL. All rights reserved.
//

import UIKit

class WBHomeViewModel: NSObject {
    
    lazy var homeList=[HomeModel]()
    
    func getData(completion:@escaping (_ isSuccess:Bool)->()) {
        let urlString="https://api.weibo.com/2/statuses/home_timeline.json"
        let params=["access_token":"2.00VtnouG0Argcn905ced97e40jiixc"]
        WBNetWorkManager.shareInstance.WBRequest(requestType: .Get, url: urlString, parameters: params, succeed: { (response) in
            //statuses
            let result=response?["statuses"] as? [[String:Any]]
            guard let array=NSArray.yy_modelArray(with: HomeModel.self, json: result ?? []) as? [HomeModel] else{
                completion(false)

                return
            }
            self.homeList = array + self.homeList
            completion(true)

        }) { (error) in
            
            print(error)
        }

    }
}





































